package com.zimin.cloud.web.controller.system;

import com.zimin.cloud.mine.pojo.system.business.AccountBO;
import com.zimin.cloud.mine.pojo.system.business.RoleBO;
import com.zimin.cloud.system.api.IAccountFeign;
import com.zimin.cloud.system.api.IRoleFeign;
import com.zimin.shared.pojo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Mono;

import javax.ws.rs.Path;
import java.util.List;

/**
 * @author zimin
 * @since 2022/1/29 5:22 下午
 */
@RestController
@RequestMapping("/web/system/role/api")
public class WebRoleController {


    @Autowired
    private IRoleFeign roleFeign;

    @GetMapping
    public Mono<Result> roleList(RoleBO roleBO) {
        return Mono.just(roleFeign.rolePageList(roleBO));
    }

    @GetMapping("/allRole")
    public Mono<Result> allRole(){
        return Mono.just(roleFeign.allRole());
    }


    @GetMapping("/{roleId}")
    public Mono<Result> getRoleById(@PathVariable(name = "roleId") String roleId) {
        return Mono.just(roleFeign.getRoleById(roleId));
    }

    @PostMapping
    public Mono<Result> save(@RequestBody RoleBO roleBO) {
        return Mono.just(roleFeign.save(roleBO));
    }

    @PutMapping
    public Mono<Result> update(@RequestBody RoleBO roleBO) {
        return Mono.just(roleFeign.update(roleBO));
    }

    @DeleteMapping
    public Mono<Result> delete(@RequestParam(value = "idList") List<String> idList) {
        return Mono.just(roleFeign.delete(idList));
    }

}
